﻿using System;
using System.IO;
using System.Collections.Generic;
using System.Text;

namespace _7DaysToDieTools
{
    /// <summary>
    /// 游戏信息存储类
    /// </summary>
    public static class Sinfo
    {
        /// <summary>
        /// 当前程序目录
        /// </summary>
        public static string PathCurr
        {
            get { return Environment.CurrentDirectory + "\\"; }
        }

        /// <summary>
        /// 游戏类型
        /// </summary>
        public static GameType gameType {
            get { return _gameType; }
            set { _gameType = value; }
        }
        private static GameType _gameType = GameType.Client;

        /// <summary>
        /// 游戏文件目录
        /// </summary>
        public static class Path
        {
            /// <summary>
            /// 配置文件目录
            /// </summary>
            public static string Config { get { return PathCurr + "Data\\Config\\"; } }
            /// <summary>
            /// 语言文件目录
            /// </summary>
            public static string Lang { get { return PathCurr + "Data\\Config\\"; } }
            /// <summary>
            /// XUI目录
            /// </summary>
            public static string XUi { get { return Config + "XUi\\"; } }
            /// <summary>
            /// 游戏数据目录
            /// </summary>
            public static string Data
            {
                get
                {
                    switch (gameType)
                    {
                        case GameType.Client:
                            return PathCurr + "7DaysToDie_Data\\";
                        case GameType.Server:
                            return PathCurr + "7DaysToDieServer_Data\\";
                    }
                    return "错误";
                }
            }
            /// <summary>
            /// 游戏DLL存放目录
            /// </summary>
            public static string Dll { get { return Data + "\\Managed\\"; } }

            /// <summary>
            /// 建筑数据存放目录
            /// </summary>
            public static string Prefabs { get { return PathCurr + "Data\\Prefabs\\"; } }
        }

        /// <summary>
        /// 游戏文件
        /// </summary>
        public static class File
        {
            /// <summary>
            /// 游戏主文件名称
            /// </summary>
            public static string GameName
            {
                get
                {
                    switch (gameType)
                    {
                        case GameType.Client:
                            return "7DaysToDie.exe";
                        case GameType.Server:
                            return "7DaysToDieServer.exe";
                    }
                    return "错误";
                }
            }
            /// <summary>
            /// 游戏主DLL名称
            /// </summary>
            public static string GameDllAssembly { get { return "Assembly-CSharp.dll"; } }

            /// <summary>
            /// XUI.xml
            /// </summary>
            public static string Xui { get { return "xui.xml"; } }
            /// <summary>
            /// styles.xml
            /// </summary>
            public static string XuiStyle { get { return "styles.xml"; } }
            /// <summary>
            /// windows.xml
            /// </summary>
            public static string XuiWindows { get { return "windows.xml"; } }
            /// <summary>
            /// controls.xml
            /// </summary>
            public static string XuiControls { get { return "controls.xml"; } }


            /// <summary>
            /// items.xml
            /// </summary>
            public static string Items { get { return "items.xml"; } }

            /// <summary>
            /// blocks.xml
            /// </summary>
            public static string Blocks { get { return "blocks.xml"; } }

            /// <summary>
            /// 主语言文件
            /// </summary>
            public static string Localization { get { return "Localization.txt"; } }
            /// <summary>
            /// 任务语言文件
            /// </summary>
            public static string LocalizationQuest { get { return "Localization - Quest.txt"; } }
            /// <summary>
            /// 开服配置文件
            /// </summary>
            public static string ServerConfig { get { return "serverconfig.xml"; } }
            /// <summary>
            /// 随机地图建筑定义文件rwgmixer.xml
            /// </summary>
            public static string RWG { get { return "rwgmixer.xml"; } }
        }

        /// <summary>
        /// 网络文件与目录
        /// </summary>
        public static class Net
        {
            /// <summary>
            /// 文件存放网络位置根目录
            /// </summary>
            public static string NetURL { get { return @"http://git.oschina.net/alwcel/AC_7DaysToDieFiles/raw/master/"; } }
            /// <summary>
            /// DLL存放位置
            /// </summary>
            public static string Dll { get { return NetURL + "DLL/"; } }
            /// <summary>
            /// MOD存放位置
            /// </summary>
            public static string Mod { get { return NetURL + "MODS/"; } }
            /// <summary>
            /// 语言文件存放位置
            /// </summary>
            public static string Lang { get { return NetURL + "LANGS/"; } }
            /// <summary>
            /// XML配置文件存放位置
            /// </summary>
            public static string Xml { get { return NetURL + "XML/"; } }
            /// <summary>
            /// 建筑数据文件存放位置
            /// </summary>
            public static string Build { get { return NetURL + "BUILD/"; } }
            /// <summary>
            /// 叠加数据文件存放位置
            /// </summary>
            public static string Stack { get { return NetURL + "STACKS/"; } }

            /// <summary>
            /// 网络存放文件名
            /// </summary>
            public static class File
            {
                /// <summary>
                /// 网上所存文件的信息文件
                /// </summary>
                public static string Config { get { return "config.xml"; } }
            }
        }

        /// <summary>
        /// 应用程序数据存放目录
        /// </summary>
        public static class Data
        {
            /// <summary>
            /// 数据存放根目录
            /// </summary>
            public static string BasePath { get { return PathCurr + "7DaysToDieTools_Data\\"; } }
            /// <summary>
            /// MOD数据目录
            /// </summary>
            public static string Mod { get { return BasePath + "Mods\\"; } }
            /// <summary>
            /// 语言数据目录
            /// </summary>
            public static string Lang { get { return BasePath + "Langs\\"; } }
            /// <summary>
            /// 叠加数据目录
            /// </summary>
            public static string Stack { get { return BasePath + "Stacks\\"; } }
            /// <summary>
            /// 建筑数据目录
            /// </summary>
            public static string Build { get { return BasePath + "Builds\\"; } }

            /// <summary>
            /// 文件名称
            /// </summary>
            public static class File
            {
                /// <summary>
                /// 建筑数据包名称
                /// </summary>
                public static string BuildFile { get { return "CompoPack24.zip"; } }
            }
        }

        /// <summary>
        /// 数据备份目录
        /// </summary>
        public static string BackPath = PathCurr + "7DaysToDieTools_Back\\";

        #region 游戏类型与检测
        /// <summary>
        /// 游戏类型
        /// </summary>
        public enum GameType
        {
            Client,
            Server
        }

        /// <summary>
        /// 检测游戏类型
        /// </summary>
        public static void Check()
        {
            DirectoryInfo di = new DirectoryInfo(PathCurr);
            if (di.GetFiles("7DaysToDie.exe").Length == 1)
            {
                gameType = GameType.Client;
            }
            else if (di.GetFiles("7DaysToDieServer.exe").Length == 1)
            {
                gameType = GameType.Server;
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("请把此工具放到游戏所在目录后再运行！");
                System.Windows.Forms.Application.Exit();
            }
            di = null;
        }
        #endregion
    }
}
